#include "sAnnounce.h"

#include <sstream>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeIterator.h>
#include "misc/Interface.h"
#include "misc/Debug.h"
#include "server/net/NetworkControl.h"
/*********************************************************/
void sAnnounce::execute()
{
	NetworkControl& net = NetworkControl::Instance();
	net.mutex->lock();
	net.nsAddr = Poco::Net::SocketAddress(addr);
	net.mutex->unlock();
}
/*********************************************************/
std::string sAnnounce::serialize() const
{
	NetworkControl& ns = NetworkControl::Instance();
	std::ostringstream		ostr;

	ostr << "<GS id='" << ns.getID() << "'>";
	ostr << "<Announce>" << addr << "</Announce>";
	ostr << "</GS>";

	return( ostr.str() );
}
/*********************************************************/
void sAnnounce::deserialize(Poco::XML::NodeIterator& it)
{
	Poco::XML::Node* pNode = it.previousNode();
	addr = pNode->innerText();
}
/*********************************************************/
void sAnnounce::setAddress(const std::string& addr)
{
	sAnnounce::addr = addr;
}
/*********************************************************/
